
#pragma once

#include <map>
#include <list>
#include <vector>
#include <string>

class Terminator
{
public:
    Terminator();
    ~Terminator();

    typedef enum {
        WORKMODE_SIMPLE,
        WORKMODE_REPLACE,
    }WorkMode;

    void setDictionary(const char * path);
    void setIgnoreTable(const char * path) { mIgnoreTablePath = path; }
    void setWorkMode(WorkMode mode);
    void setWordCount(int c) { mWordCount = c; }

    int start(std::string words);

private:
    std::string                 mDictionaryPath;
    std::string                 mIgnoreTablePath;
    std::vector<std::string>    v;
    std::list<std::string>      result_table;
    std::vector<std::string>    mIgnoreTable;
    WorkMode                    mWorkMode;
    int                         mWordCount;


    int readDictionary(std::string words);
    void readIgnoreTable();
    bool isInIgnoreTable(std::string word);

    bool canSpell(std::string word, std::string chars);
    bool isNewResult(std::string result);
    int  deal(std::string words);

    std::map<char, char>        mReplaceMap;
};




